import smtplib
from email.header import Header
from email.mime.text import MIMEText
from email.utils import parseaddr, formataddr

def _format_addr(s):
    name, addr = parseaddr(s)
    return formataddr((Header(name, 'utf-8').encode(), addr))

from_addr = 'huhongxiang@csii.com.cn'
password = 'ch931129'
to_addr = '768012449@qq.com'
smtp_server = 'smtpcom.263xmail.com'

msg = MIMEText('<html><body><h1>Hello</h1>' +
               '<p>send by <a href="http://www.python.org">Python</a>...</p>' +
               '</body></html>', 'html', 'utf-8')
msg['From'] = _format_addr('huhx <%s>' % from_addr)
msg['To'] = _format_addr('linux <%s>' % to_addr)
msg['Subject'] = Header('subject info', 'utf-8').encode()

server = smtplib.SMTP(smtp_server, 465)
server.set_debuglevel(1)
server.login(from_addr, password)
server.sendmail(from_addr, [to_addr], msg.as_string())
server.quit()
